﻿Create PROCEDURE [dbo].[proc_Customer_SearchCusName_GK]
	(
		@CusName nvarchar(50),
		@UserName nvarchar(50)
	)
AS
BEGIN
	DECLARE @CompanyId int
	Select @CompanyId=CompanyId From Employee Where UserName=@UserName
	
	Select
	Id,
	CustomerId,
	CustomerName,
	MnemonicWorks,
	Tel,
	(Select Title From Customer_Protect Where Id=Customer.ProtectId) As Protect,
	(Select EName From Employee Where UserName=Customer.CreateName) As CreateNameEName,
	CreateDate 
	From Customer Where CompanyId=@CompanyId And CustomerName=@CusName And ProtectId=1
END
	RETURN